#ifndef					__LISTENER_H_
# define				__LISTENER_H_

# include				<QObject>
# include				<qDebug>
# include				<string>
# include				<cstdlib>
# include				<portaudio/portaudio.h>
# include				<queue>
# include				<qmutex.h>
# include				"SoundPacket.h"
# include				"RingBuffer.h"
# include				"soundbuffer.h"

class					Recorder : public QObject
{
	Q_OBJECT

public:
	Recorder(QObject *parent = 0);
	~Recorder();

public:
	void				init();
	int					record(const short *);
	void				start();
	void				stop();
	size_t				getFPB() const;
	size_t				getChannelNB() const;
	size_t				getSampleRate() const;
//	void				read(ISoundPacket*);
	SoundPacket			*getSoundPacket();

private:
	int					getCableDevice();
//	SoundRotatingBuffer	_buffer;
	int					_frameIndex;
	PaStream			*_stream;
	size_t				_sample_rate;
	size_t				_frames_per_buffer;
	size_t				_num_channels;
	int					_status;
	RingBuffer			_buffer;
	SoundBuffer			_soundBuff;

signals:
	void				_readBufferFull();
	void				newBuffer(short *);
};

#endif // !__LISTENER_H_
